﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using BSCMFF.Core.DataAccessLayer;

namespace BSCMFF.Web.Pages.working
{
    public partial class TestListboxTransfer : BSCMFF.Core.MultiLanguagePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //RadListBox1.LoadContentFile("ListBox.xml");
                //RadListBox2.LoadContentFile("ListBox.xml");

                BSCEntities context = new BSCEntities();
                var users = (from user in context.Users
                             select user).ToList();

                RadListBox1.DataSource = users;
                RadListBox2.DataSource = users;

                
                RadListBox1.DataValueField = "ID";
                RadListBox1.DataTextField = "Fullname";


                RadListBox2.DataValueField = "ID";
                RadListBox2.DataTextField = "Fullname";

                RadListBox1.DataBind();
                RadListBox2.DataBind();

            }

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //LogClientOperations(RadListBox1);
            //LogClientOperations(RadListBox2);
            //LogClientOperations(RadListBox3);
        }

        //private void LogClientOperations(RadListBox listBox)
        //{
        //    foreach (ClientOperation<RadListBoxItem> operation in listBox.ClientChanges)
        //    {
        //        RadListBoxItem item = operation.Item;

        //        switch (operation.Type)
        //        {
        //            case ClientOperationType.Insert:
        //                EventLogConsole1.LoggedEvents.Add(listBox.ID + "=>Added item with text: \"" + item.Text + "\"");
        //                break;
        //            case ClientOperationType.Remove:
        //                EventLogConsole1.LoggedEvents.Add(listBox.ID + "=>Removed item with text: \"" + item.Text + "\"");
        //                break;
        //            case ClientOperationType.Update:
        //                UpdateClientOperation<RadListBoxItem> update = (UpdateClientOperation<RadListBoxItem>)operation;
        //                EventLogConsole1.LoggedEvents.Add(listBox.ID + "=>The \"" + update.PropertyName + "\" property of the \"" + item.Text + "\" item changed.");
        //                break;
        //            case ClientOperationType.Reorder:
        //                ReorderClientOperation<RadListBoxItem> reorder = (ReorderClientOperation<RadListBoxItem>)operation;
        //                EventLogConsole1.LoggedEvents.Add(listBox.ID + "=>The item with text \"" + item.Text + "\" item reordered from " + reorder.OldIndex + " to " + reorder.NewIndex);
        //                break;
        //        }
        //    }
        //}
    }
}